package leetcode.editor.cn.q1_300.q150;

/**
 * @author qidi
 * @date 2022-02-10 14:51:11
 */
class Q0168_ExcelSheetColumnTitle {

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public String convertToTitle(int columnNumber) {
            StringBuilder sb = new StringBuilder();

            while (columnNumber > 0) {
                int res = (columnNumber - 1) % 26;
                sb.insert(0, (char) (res + 'A'));
                columnNumber = (columnNumber - res + 1) / 26;
            }

            return sb.toString();
        }
    }
    //leetcode submit region end(Prohibit modification and deletion)


    public static void main(String[] args) {
        Solution solution = new Q0168_ExcelSheetColumnTitle().new Solution();
        System.out.println(solution.convertToTitle(52));
        System.out.println(solution.convertToTitle(726));
        System.out.println(solution.convertToTitle(600));
        System.out.println(solution.convertToTitle(701));
        System.out.println(solution.convertToTitle(1));
        System.out.println(solution.convertToTitle(28));
        System.out.println(solution.convertToTitle(2147483647));
    }
}